package com.crm.service.impl.customerManager;


import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.customerManager.ExchangeMapper;
import com.crm.model.entity.customerManager.CustomerContactPerson;
import com.crm.model.entity.customerManager.CustomerContactPersonExample;
import com.crm.model.entity.customerManager.Exchange;
import com.crm.model.entity.customerManager.ExchangeExample;
import com.crm.service.customerManager.CustomerExchangeDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ Author ：baijian
 * @ Date   ：2021/5/7 11:10
 */
@Service
public class CustomerExchangeDbServiceImpl implements CustomerExchangeDbService {

    @Autowired
    private ExchangeMapper exchangeMapper;

    /**
     * 客户详情-兑换列表
     * @param order 分组数据
     * @param customerId 客户id
     * @return
     */
    @Override
    public List<Exchange> exchangeList(String order, String customerId) {
        ExchangeExample exchangeExample = new ExchangeExample();
        exchangeExample.setOrderByClause(order);
        ExchangeExample.Criteria criteria = exchangeExample.createCriteria();
        criteria.andCustomerIdEqualTo(customerId);
        criteria.andDeleteStatusEqualTo(Short.parseShort(String.valueOf(StatusCodeEnum.NORMAL_CODE.getState())));
        List<Exchange> list = exchangeMapper.selectByExample(exchangeExample);
        return list;
    }

    /**
     * 通过兑换id查询兑换记录
     * @param exchangeId 兑换id
     * @return
     */
    @Override
    public Exchange getExchangeById(String exchangeId) {
        return exchangeMapper.selectByPrimaryKey(exchangeId);
    }


}
